package com.zp.self;

import com.zp.self.spring.循环依赖.BeanA;
import com.zp.self.spring.循环依赖.BeanB;
import com.zp.self.springboot.z_启动过程.组件.Person;
import org.springframework.aop.support.AopUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurationExcludeFilter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.TypeExcludeFilter;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;

import javax.annotation.Resource;

/**
 * Hello world!
 */
//@SpringBootApplication
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @ComponentScan.Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
                                  @ComponentScan.Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public class SpringbootApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(new Class[]{SpringbootApplication.class, Person.class}, args);

        BeanA beanA = context.getBean(BeanA.class);
        BeanB beanB = context.getBean(BeanB.class);
        BeanB beanBInBeanA = beanA.getBeanB();
        BeanA beanAInBeanB = beanB.getBeanA();
        System.out.println("BeanA是否为代理对象：" + AopUtils.isAopProxy(beanA));
        System.out.println("BeanB是否为代理对象：" + AopUtils.isAopProxy(beanB));
        System.out.println("beanAInBeanB是否为代理对象：" + AopUtils.isAopProxy(beanAInBeanB));

        System.out.println(beanB == beanBInBeanA);
        System.out.println(beanA == beanAInBeanB);


    }


}
